﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectEmployees.aspx.cs" Inherits="Skyworth.CRM.Web.BasicData.SelectEmployees" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>选择员工</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <link href="../themes/default/style.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/core.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/pages.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/wbox.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/Messagebox.css" rel="stylesheet" type="text/css" />

    <script src="../javascripts/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script src="../javascripts/json2.js" type="text/javascript"></script>

    <script src="../javascripts/dwz.core.js" type="text/javascript"></script>

    <script src="../javascripts/MessageBox.js" type="text/javascript"></script>

    <script src="../javascripts/dwz.pagination.js" type="text/javascript"></script>
    <style type="text/css">
    html{
        overflow-x:hidden;
    }
     .content
        {
            overflow: auto;
            border: solid 1px #CCC;
            line-height: 21px;
            background: #FFF;
            padding: 2px;
        }
        .linkDisabled
        {
        	color:Gray;
        }
    </style>
    <script type="text/javascript">
        //下一页
        function dwzPageBreak(args) {
            $("#pageNum").val(args["pageNum"]);
            GetEmpolyees();
        }

        //设置翻页    
        function SetPager(pagerId, pageMsgId, numPerPage, currentPage, totalRecords, totalPages) {
            $(pageMsgId).text("  共【" + totalRecords + "】条，【" + totalPages + "】页");
            $(pagerId).each(function () {
                var $this = $(this);
                $this.pagination({
                    targetType: $this.attr("targetType"),
                    totalCount: totalRecords,
                    numPerPage: numPerPage,
                    pageNumShown: $(this).attr("pageNumShown"),
                    currentPage: currentPage
                });
            });
        }

        function GetEmpolyees() {
            //debugger;
            var paramList = new Object();
            paramList.Department = $("#ddlDepartment").val();
            paramList.EmpCno = $("#txtEmpCno").val();
            paramList.EmpName = $("#txtEmpName").val();
            paramList.orderField = $("#orderField").val();
            paramList.orderValue = $("#orderValue").val();
            paramList.pageIndex = $("#pageNum").val();
            paramList.pagePerSize = $("#numPerPageSelect").val();
            $.ajax({
                type: "POST",
                url: "SelectEmployees.aspx/GetEmpolyees",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(paramList),
                dataType: "json",
                success: function (data) {
                    var dataTable = jQuery.parseJSON(data.d);
                    //填充数据
                    $("#empList tbody").empty();
                    var lists = "";
                    $.each(dataTable.rows, function (i, item) {
                        lists = lists + "<tr rel='" + item.EmpId + "'>" +
                        "<td>" + item.EmpCode + "</td>" +
                        "<td>" + item.EmpName + "</td>" +
                        "<td>" + item.DepartmentName + "</td>" +                        
                        "<td>" + item.JobTitle + "</td>" +
                        "<td>" + item.Email + "</td>" +
                        "<td>" + item.Phone + "</td>" +
                        "</tr>";
                    })
                    $(lists).appendTo($("#empList tbody"));

                    //绑定事件
                    $("#empList tr:nth-child(even)").attr('class', "trbg");
                    $("#empList tbody tr").click(function () {
                        $(this).addClass("selected");
                        $(this).siblings("tr").removeClass("selected");
                    }).hover(function () {
                        $(this).addClass('hover');
                    }, function () {
                        $(this).removeClass('hover');
                    })
                    SetPager("div.pagination", "#pageMsg", $("#numPerPageSelect").val(), $("#pageNum").val(), dataTable.totalRecords, dataTable.totalPages);
                },
                error: function (msg) { $.Messager.Alert({ Title: '系统消息', Message: "发生异常，获取员工数据失败！", Icon: IconType.Warning }); },
                beforeSend: function () { $("#LoadingPanel").fadeIn("slow"); },
                complete: function () { $("#LoadingPanel").fadeOut("fast"); }
            })
        }
        function SelectOneCustomer() {
            var empId = $("#empList tbody tr.selected:eq(0)").attr("rel");
            var empName = $("#empList tbody tr.selected:eq(0)").find("td").eq(1).text();
            var pareForm = window.opener;
            var PID = pareForm.document.getElementById("hidEmpId");
            var PName = pareForm.document.getElementById("txtEmployee");
            PName.value = empName;
            PID.value = empId;
            window.close(); 
            return false;
        }
        $(document).ready(function () {
            GetEmpolyees();
            $("#btnSearch").click(function () {
                //debugger;
                GetEmpolyees();
                return false;
            })
            $("#numPerPageSelect").change(function () {
                $("#pageNum").val(1);
                GetEmpolyees();
            })
            $("#btnClose").click(function () {
                parent.addWindow.close();
            })
            // init styles
            $("input[type=text]").addClass("textInput").focusClass("focus");
            $("div.button").hover(function () { $(this).addClass("buttonHover"); },
                                 function () { $(this).removeClass("buttonHover"); });
            $("div.buttonActive").hover(function () { $(this).addClass("buttonActiveHover"); },
                                function () { $(this).removeClass("buttonActiveHover"); })
            $("#empList thead th[colName]").click(function () {
                $("#orderField").val($(this).attr("colName"));
                if ($(this).hasClass("headerSortUp")) {
                    $("#orderValue").val("desc");
                    $(this).removeClass("headerSortUp").addClass("headerSortDown");
                }
                else {
                    $("#orderValue").val("asc");
                    $(this).removeClass("headerSortDown").addClass("headerSortUp");
                }
                $(this).siblings("th").removeClass("headerSortUp").removeClass("headerSortDown");
                $("#pageNum").val(1);
                GetEmpolyees();
            })
        })    
    </script>
</head>
<body style="background-color: White;overflow:visible">
    <div>
        <form id="form1" runat="server">
        <div class="panel" id="policyPanel">
                <div class="panelHeader">
                    <div class="panelHeaderContent">
                        <h1>
                            选择客户</h1>                            
                    </div>
                </div>
                <div class="panelContent">
                    <div class="content">
        <table width="100%">
            <tr>
                <td>
                   <div class="searchBar" style="padding: 4px 5px;">
                        <table>
                            <tr>
                                <td>
                                    <span>所属部门：</span>
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlDepartment" runat="server" style="height:23px;line-height:23px;">
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    <span style="margin-left:10px">员工编号：</span>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtEmpCno" runat="server"></asp:TextBox>
                                </td>
                                <td>
                                    <span style="margin-left:10px">员工姓名：</span>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtEmpName" runat="server"></asp:TextBox>
                                </td>
                                <td >
                                    <div class="buttonActive" style="margin-left:10px">
                                        <div class="buttonContent">
                                            <asp:Button ID="btnSearch" runat="server" Text="查询" ToolTip="查询员工信息" CssClass="serverButton" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>           
            <tr>
                <td>
                    <div class="pageContent" style="_margin-top:-2px;">
                         <div class="tableList">
                        <table class="list" id="empList" width="100%">
                            <thead>
                                <tr>
                                    <th style="cursor: pointer;" colname="EmpCode">
                                        <span style="float: left">员工编码</span> <span style="float: right;" class="sortIcon">
                                        </span>
                                    </th>
                                    <th style="cursor: pointer;" class="headerSortUp" colname="EmpName">
                                        <span style="float: left">员工姓名</span> <span style="float: right;" class="sortIcon">
                                        </span>
                                    </th>
                                    <th style="cursor: pointer;" colname="DepartmentName">
                                        <span style="float: left">所属部门</span> <span style="float: right;" class="sortIcon">
                                        </span>
                                    </th>
                                    <th style="cursor: pointer;" colname="JobTitle">
                                        <span style="float: left">职务</span><span style="float: right;" class="sortIcon">
                                    </th>
                                    <th style="cursor: pointer;" colname="Email">
                                        <span style="float: left">邮箱地址</span><span style="float: right;" class="sortIcon">
                                    </th>
                                    <th style="cursor: pointer;" colname="Phone">
                                        <span style="float: left">联系电话</span><span style="float: right;" class="sortIcon">
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                    <div class="panelBar">
                        <div class="pages">
                            <span>每页显示</span>
                            <div style="float: left">
                                <select id="numPerPageSelect" runat="server">
                                    <option>15</option>
                                    <option>20</option>
                                    <option>25</option>
                                    <option selected="selected">30</option>
                                    <option>35</option>
                                    <option>40</option>
                                    <option>45</option>
                                    <option>50</option>
                                </select>
                            </div>
                            <span id="pageMsg"></span>
                        </div>
                        <div class="pagination" targettype="navTab" pagenumshown="3">
                        </div>
                        <div style="clear: both; float: none; display: none;">
                        </div>
                    </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="hidden" id="pageNum" name="pageNum" value="1" runat="server" />
                    <input type="hidden" id="orderField" name="orderField" value="EmpCode" runat="server" />
                    <input type="hidden" id="orderValue" name="orderValue" value="desc" runat="server" />
                </td>
            </tr>
            <tr>
                <td style="padding-right: 12px; height: 30px; background: url('../themes/default/images/grid/grid.png') repeat scroll 0 0">
                   <div>
                    <a title="清空" href="javascript:void(0);" class="button" style="float: left" id="btnClose">
                        <span>关闭</span></a>
                    <div class="button" style="float: right; margin-right: 5px;">
                        <div class="buttonContent">
                            <asp:Button ID="btnSave" runat="server" Text="确定" CssClass="serverButton" OnClientClick="return SelectOneCustomer();" />
                        </div>
                    </div>
                    <div style="clear: both; float: none; display: none;">
                    </div>
                    </div>
                </td>
            </tr>
        </table>
         </div>
                </div>
                <div class="panelFooter">
                    <div class="panelFooterContent">
                    </div>
                </div>
            </div>
        </form>
         <div id="LoadingPanel" style="display: none;">
            <div id='background' class='background'>
            </div>
            <div id='progressBar' class='progressBar'>
                数据加载中，请稍等...</div>
        </div>
    </div>
</body>
</html>